package cannot.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cannot.mapper.RemarkMapper;
import cannot.pojo.Remark;
import cannot.pojo.RemarkExample;
import cannot.service.RemarkService;
@Service
public class RemarkServiceImpl implements RemarkService {
	@Autowired
	RemarkMapper remarkMapper;

	@Override
	public List<Remark> listRemarkByTvId(Integer id) {
		return remarkMapper.listRemarkByTvId(id);
	}

	@Override
	public void insertRemark(Remark remark) {
		remarkMapper.insert(remark);
	}

	@Override
	public Double avgTv(Integer id) {
		return remarkMapper.avgTv(id);
	}

	@Override
	public void deleteByTvId(Integer id) {
		RemarkExample example = new RemarkExample();
		example.createCriteria().andTv_idEqualTo(id);
		List<Remark> remarks = remarkMapper.selectByExample(example);
		for(Remark remark:remarks){
			remarkMapper.deleteByPrimaryKey(remark.getId());
		}
	}

}
